exports.Register = {
	email: [
		{
			type: 'isEmail',
			message: '不符合Email规范'
		}
	],
	password1: [
		{
			type: 'isLength',
			message: '密码至少6个字符，最多32个字符',
			options: {
				min: 6,
				max: 32
			}
		},
		{
			type: 'matches',
			message: '密码不符合规范',
			options: '^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]'
		}
	],
	password2: 'password1',

	validatePassword(vals) {
		const psw1 = vals.body.password1
		const psw2 = vals.body.password2
		if (psw1 !== psw2) {
			throw new Error('两个密码必须相同')
		}
	},

	async validateEmail(vals) {
		const email = vals.body.email
		const user = await User.findOne({
			where: {
				email: email
			}
		})
		if (user) {
			throw new Error('email已存在')
		}
	}
}
